var mapIds = [811000100, 811000200, 811000300, 811000400, 811000500];
var 准备地图 = 811000999;

function init() {}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance("Boss_比睿山_浓姬");
    for (var b = 0; b < mapIds.length; b++) {
        var e = c.setInstanceMap(mapIds[b]);
        e.resetFully();
        e.respawn(true)
    }
    var e = c.getMapInstance(811000500);
    var d = em.getMonster(9450022);
    e.spawnMonsterOnGroundBelow(d, new java.awt.Point(-4, -205));
    em.setProperty("kill", "0");
    em.setProperty("clear", "0");
    return c
}

function onPlayerRegistered(b, a) {
    a.setReviveCount(5);
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0));
    b.startEventTimer(30 * 60 * 1000)
}

function onPlayerRevived(b, a) {
    return false
}

function onMapChanged(c, b, a) {
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
    if (b.getMap().getNumMonsters() == 0) {
        b.getAPI().fieldEffect_SetObjectState(10000, "Pt01gate")
    } else {
        if (b.getMapId() == 811000500) {
            b.getAPI().npc_ChangeController(9130110, "bg1", -543, -389, 0);
            b.getAPI().npc_ChangeController(9130111, "bg2", -415, -569, 0);
            b.getAPI().npc_ChangeController(9130112, "bg3", 0, -682, 0);
            b.getAPI().npc_ChangeController(9130113, "bg4", 415, -589, 0);
            b.getAPI().npc_ChangeController(9130114, "bg5", 543, -409, 0)
        }
    }
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onMonsterKilled(b, c) {
    var a = em.getNumberProperty("stage" + player.getMapId() + "_kill") + 1;
    em.setProperty("stage" + player.getMapId() + "_kill", a);
    if (player.getMapId() == 811000100) {
        if (a == 17) {
            player.getAPI().playerMessage(-1, "浓姬的召唤兽出现了。");
            player.getAPI().spawnMobLimit(9450004, 1, 354, -562, 1)
        } else {
            if (a == 18) {
                b.getPlayers().forEach(function (d) {
                    d.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
                    d.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
                    d.getAPI().fieldEffect_SetObjectState(10000, "Pt01gate")
                })
            }
        }
    } else {
        if (player.getMapId() == 811000200) {
            if (a == 8) {
                b.getPlayers().forEach(function (d) {
                    d.getAPI().playerMessage(-1, "在魔法师气运的影响下，被召唤出来的织田军剑士力量遭到了削减。")
                });
                player.getAPI().spawnMobLimit(9450006, 1, -580, -4, 100);
                player.getAPI().spawnMobLimit(9450006, 1, -530, -4, 100);
                player.getAPI().spawnMobLimit(9450006, 1, -480, -4, 100);
                player.getAPI().spawnMobLimit(9450006, 1, -430, -4, 100);
                player.getAPI().spawnMobLimit(9450006, 1, -380, -4, 100);
                player.getAPI().spawnMobLimit(9450006, 1, -330, -4, 100);
                player.getAPI().spawnMobLimit(9450006, 1, -280, -4, 100);
                player.getAPI().spawnMobLimit(9450006, 1, -230, -4, 100)
            } else {
                if (a == 16) {
                    b.getPlayers().forEach(function (d) {
                        d.getAPI().playerMessage(-1, "在弓箭手气运的影响下，被召唤出来的织田军剑士力量遭到了削减。")
                    });
                    player.getAPI().spawnMobLimit(9450007, 1, 130, -147, 100);
                    player.getAPI().spawnMobLimit(9450007, 1, 180, -147, 100);
                    player.getAPI().spawnMobLimit(9450007, 1, 230, -147, 100);
                    player.getAPI().spawnMobLimit(9450007, 1, 280, -147, 100);
                    player.getAPI().spawnMobLimit(9450007, 1, 330, -147, 100);
                    player.getAPI().spawnMobLimit(9450007, 1, 380, -147, 100);
                    player.getAPI().spawnMobLimit(9450007, 1, 430, -147, 100);
                    player.getAPI().spawnMobLimit(9450007, 1, 480, -147, 100)
                } else {
                    if (a == 24) {
                        b.getPlayers().forEach(function (d) {
                            d.getAPI().playerMessage(-1, "在盗贼气运的影响下，被召唤出来的织田军剑士力量遭到了削减。")
                        });
                        player.getAPI().spawnMobLimit(9450008, 1, -580, -298, 100);
                        player.getAPI().spawnMobLimit(9450008, 1, -530, -298, 100);
                        player.getAPI().spawnMobLimit(9450008, 1, -480, -298, 100);
                        player.getAPI().spawnMobLimit(9450008, 1, -430, -298, 100);
                        player.getAPI().spawnMobLimit(9450008, 1, -380, -298, 100);
                        player.getAPI().spawnMobLimit(9450008, 1, -330, -298, 100);
                        player.getAPI().spawnMobLimit(9450008, 1, -280, -298, 100);
                        player.getAPI().spawnMobLimit(9450008, 1, -230, -298, 100)
                    } else {
                        if (a == 32) {
                            b.getPlayers().forEach(function (d) {
                                d.getAPI().playerMessage(-1, "在海盗气运的影响下，被召唤出来的织田军剑士力量遭到了削减。")
                            });
                            player.getAPI().spawnMobLimit(9450009, 1, 0, -497, 100);
                            player.getAPI().spawnMobLimit(9450009, 1, 50, -497, 100);
                            player.getAPI().spawnMobLimit(9450009, 1, 100, -497, 100);
                            player.getAPI().spawnMobLimit(9450009, 1, 150, -497, 100);
                            player.getAPI().spawnMobLimit(9450009, 1, 200, -497, 100);
                            player.getAPI().spawnMobLimit(9450009, 1, 250, -497, 100);
                            player.getAPI().spawnMobLimit(9450009, 1, 300, -497, 100);
                            player.getAPI().spawnMobLimit(9450009, 1, 350, -497, 100)
                        } else {
                            if (a == 40) {
                                b.getPlayers().forEach(function (d) {
                                    d.getAPI().playerMessage(-1, "打倒莲花后，才能继续前往下一层。");
                                    d.getAPI().playerMessage(5, "打倒莲花后，才能继续前往下一层。")
                                });
                                player.getAPI().spawnMobLimit(9450010, 1, 200, -497, 1)
                            } else {
                                if (a == 41) {
                                    b.getPlayers().forEach(function (d) {
                                        d.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
                                        d.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
                                        d.getAPI().fieldEffect_SetObjectState(10000, "Pt01gate")
                                    })
                                }
                            }
                        }
                    }
                }
            }
        } else {
            if (player.getMapId() == 811000300) {
                if (a == 15) {
                    b.getPlayers().forEach(function (d) {
                        d.getAPI().playerMessage(-1, "翁罗将军的召唤兽正在试图破坏封印球。");
                        d.getAPI().playerMessage(5, "翁罗将军的召唤兽正在试图破坏封印球。")
                    });
                    player.getAPI().spawnMobLimit(9450013, 1, 53, -262, 1);
                    player.getAPI().spawnMobLimit(9450012, 1, -410, -262, 5);
                    player.getAPI().spawnMobLimit(9450012, 1, -410, -27, 5);
                    player.getAPI().spawnMobLimit(9450012, 1, 53, -27, 5);
                    player.getAPI().spawnMobLimit(9450012, 1, 504, -25, 5);
                    player.getAPI().spawnMobLimit(9450012, 1, 500, 260, 5);
                    player.getAPI().spawnMobLimit(9450011, 1, -410, -262, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, -410, -262, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, -410, -262, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, -410, -262, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, -410, -262, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, -410, -27, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, -410, -27, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, -410, -27, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, -410, -27, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, -410, -27, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 53, -27, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 53, -27, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 53, -27, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 53, -27, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 53, -27, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 504, -25, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 504, -25, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 504, -25, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 504, -25, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 504, -25, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 500, 260, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 500, 260, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 500, 260, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 500, 260, 25);
                    player.getAPI().spawnMobLimit(9450011, 1, 500, 260, 25)
                } else {
                    if (a == 40) {
                        player.getMap().killAllMonsters(true);
                        player.getMap().getWeatherEffectNotice("居然能让我变得如此虚弱……你们确实比我之前见到的家伙都要强啊。", 166, 30000, 1);
                        player.getAPI().spawnMobLimit(9450014, 1, 41, 146, 1)
                    } else {
                        if (c == 9450014) {
                            b.getPlayers().forEach(function (d) {
                                d.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
                                d.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
                                d.getAPI().fieldEffect_SetObjectState(10000, "Pt01gate")
                            })
                        }
                    }
                }
            } else {
                if (player.getMapId() == 811000400) {
                    if (a == 13) {
                        b.getPlayers().forEach(function (d) {
                            d.getAPI().playerMessage(-1, "弥弄矩出现了，一定要多加小心啊。");
                            d.getAPI().playerMessage(5, "弥弄矩出现了，一定要多加小心啊。")
                        });
                        player.getAPI().spawnMobLimit(9450020, 1, 172, -134, 1)
                    } else {
                        if (a == 14) {
                            b.getPlayers().forEach(function (d) {
                                d.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
                                d.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
                                d.getAPI().fieldEffect_SetObjectState(10000, "Pt01gate")
                            })
                        }
                    }
                } else {
                    if (player.getMapId() == 811000500) {
                        if (c == 9450022) {
                            player.getMap().killAllMonsters(true);
                            b.getPlayers().forEach(function (d) {
                                d.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
                                d.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
                                d.getAPI().fieldEffect_SetObjectState(10000, "Pt01gate");
                                d.getAPI().npc_LeaveField("bg1");
                                d.getAPI().npc_LeaveField("bg2");
                                d.getAPI().npc_LeaveField("bg3");
                                d.getAPI().npc_LeaveField("bg4");
                                d.getAPI().npc_LeaveField("bg5")
                            })
                        }
                    }
                }
            }
        }
    }
    return 1
}

function onPlayerRevived(b, a) {
    return false
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}

function onMonsterDamaged() {}

function onItemPickedUp() {}
var setupTask;

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
};